package com.wiki.gds.backstage.admin.controller.sys;


import com.wiki.gds.base.common.dto.ResponseDto;
import com.wiki.gds.base.common.exception.BizExceptionEnum;
import com.wiki.gds.base.common.utils.ResponseDtoFactory;
import com.wiki.gds.base.web.controller.common.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.RememberMeServices;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
public class LoginController extends BaseController {

//    @Autowired
//    private AuthenticationManager authenticationManager;
//
//    @Autowired(required = false)
//    private RememberMeServices rememberMeServices;
//
//    @Autowired(required = false)
//    private ApplicationEventPublisher eventPublisher;
//
//
    @RequestMapping(value = "login",method = RequestMethod.GET)
    public ResponseDto getLogin(String userName,String passWord){
        ResponseDto rs= ResponseDtoFactory.GetInstance().build(BizExceptionEnum.SUCCESSFUL_OPERATION);
        String ss="请登录";
        rs.setData(ss);

        return rs;
    }


//
//    @RequestMapping(value = "login",method = RequestMethod.POST)
//    public ResponseDto Login(String userName,String passWord){
//       ResponseDto rs= ResponseDtoFactory.GetInstance().build(BizExceptionEnum.SUCCESSFUL_OPERATION);
//        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("admin", "123456");
//
//        Authentication authResult = authenticationManager.authenticate(token);
//
//        SecurityContextHolder.getContext().setAuthentication(authResult);
//        // 发布登陆成功事件
//        if (eventPublisher != null) {
//            eventPublisher.publishEvent(new InteractiveAuthenticationSuccessEvent(authResult, this.getClass()));
//        }
//      return rs;
//    }
//
//
//    @RequestMapping(value="/logout", method = RequestMethod.POST)
//    public String logoutPage () {
//        return "登出啦";//You can redirect wherever you want, but generally it's a good practice to show login screen again.
//    }


}
